package com.bys.ots.config.wx.job;

import com.bys.ots.config.wx.WxTokenUpdate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
@Configuration
@EnableScheduling

public class JobWxTokenUpdate implements ApplicationRunner
{
    private final Logger logger = LoggerFactory.getLogger(JobWxTokenUpdate.class);
    @Resource
    private WxTokenUpdate wxTokenUpdate;

    @Scheduled(cron = "0 0 */1 * * ?")
    // @Scheduled(cron = "0 */1 * * * ?")
    private void update() {
        logger.info("定时任务更新微信token");
        wxTokenUpdate.updateToken();
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        update();
    }
}
